$(function () {
    //创建两个数组
    var prices = new Array();
    var times = new Array();

    //使用ajax方法得到服务器端数据
    $.get("all",function (data) {
        for (var i = 0; i < data.length; i++) {
            for (var j = 0; j < data[i].length; j++) {
                prices[j]=data[i][j].goodsPrice;
                times[j]=data[i][j].time.toString().substring(0,10);
            }
            $("#container_"+data[i][0].goodsId).highcharts({
                credits: {
                    text: '比价网',
                    href: 'http://localhost:8080',
                    position: {                         // 位置设置
                        align: 'right',
                        x: -15,
                        y: -15
                    },
                    style: {                            // 样式设置
                        cursor: 'pointer'
                    }
                },
                title:{
                    text:"价格变动",
                    style: {
                        "color":"red",
                        "font-size":"20px",
                        "font-family":"楷体"
                    }
                },
                xAxis:{
                    categories:times,
                    dateTimeLabelFormats: {
                        month: '%Y-%m-%d'
                    }
                },
                yAxis:{
                    title: {
                        min:0,
                        text: "价格"
                    }
                },
                //数据数列
                series:[{
                    name:"价格",
                    data:prices
                }]
            });
            // $("#container_"+data[i][0].goodsId).highcharts(options);
            prices = [];
            times = [];
        }
    })
});